#include <iostream>


using namespace std;
using ll=long long;
const int N=1e5+10;

ll a[N];

int n,m;
struct node{
	int l,r;
	ll sum;
	ll lazy;
}tr[N*4];
void pushup(int u)
{
	tr[u].sum=tr[u<<1].sum+tr[u<<1|1].sum;
}
void pushdown(int u)
{
	if(tr[u].lazy!=0)
	{
		tr[u<<1].lazy+=tr[u].lazy;
		tr[u<<1].sum+=(tr[u<<1].r-tr[u<<1].l+1)*tr[u].lazy;
		tr[u<<1|1].lazy+=tr[u].lazy;
		tr[u<<1|1].sum+=(tr[u<<1|1].r-tr[u<<1|1].l+1)*tr[u].lazy;
		tr[u].lazy=0;
	}
}
void build(int u,int l,int r)
{
	if(l==r)
	{
		tr[u]={l,r,a[l],0};
	}
	else{
		tr[u]={l,r};
		int mid=l+r>>1;
		build(u<<1,l,mid);
		build(u<<1|1,mid+1,r);
		pushup(u);
	}
	
}
void modify(int u,int l,int r,int d)
{
	if(tr[u].l>=l && tr[u].r<=r)
	{
		tr[u].lazy+=d;
		tr[u].sum+=(tr[u].r-tr[u].l+1)*d;
	}
	else{
		pushdown(u);
		int mid=tr[u].l+tr[u].r>>1;
		if(l<=mid)
		{
			modify(u<<1,l,r,d);
		}
		if(r>mid)
		{
			modify(u<<1|1,l,r,d);
		}
		
		
		pushup(u);
	}
}
ll query(int u,int l,int r)
{
	if(tr[u].l>=l && tr[u].r<=r)
	{
		return tr[u].sum;
	}
	pushdown(u);
	int mid=tr[u].l+tr[u].r>>1;
	ll ret=0;
	if(l<=mid)
	{
		ret=query(u<<1,l,r);
	}
	if(r>mid)
	{
		ret+=query(u<<1|1,l,r);
	}
	return ret;
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		
	}
	build(1,1,n);
	while(m--)
	{
		int op,x,y;
		scanf("%d%d%d",&op,&x,&y);
		if(op==1)
		{
			int d;
			scanf("%d",&d);
			modify(1,x,y,d);
		}
		else{
			cout<<query(1,x,y)<<endl;
		}
	}
	
	return 0;
}
